package com.eric.code.toucheventdemo.view;

import android.content.Context;
import android.util.AttributeSet;
import android.util.Log;
import android.view.MotionEvent;
import android.widget.TextView;

import com.eric.code.toucheventdemo.utils.TouchUtils;

/**
 * Created by eric on 16-7-5.
 */
public class MyTextView extends TextView {
    private static final String TAG = "MyTextView" ;
    private boolean dispatch,touch ;
    public MyTextView(Context context) {
        super(context);
    }

    public MyTextView(Context context, AttributeSet attrs) {
        super(context, attrs);
    }

    public MyTextView(Context context, AttributeSet attrs, int defStyleAttr) {
        super(context, attrs, defStyleAttr);
    }

    @Override
    public boolean dispatchTouchEvent(MotionEvent event) {
        Log.w(TAG,"dispatchTouchEvent -> "+ TouchUtils.getTouchAction(event.getAction())) ;
        if(dispatch)return true;
        return super.dispatchTouchEvent(event);
    }

    @Override
    public boolean onTouchEvent(MotionEvent event) {
        Log.w(TAG,"onTouchEvent -> "+ TouchUtils.getTouchAction(event.getAction())) ;
        if(touch)return true;
        return super.onTouchEvent(event);
    }

    public boolean isDispatch() {
        return dispatch;
    }

    public void setDispatch(boolean dispatch) {
        this.dispatch = dispatch;
    }

    public boolean isTouch() {
        return touch;
    }

    public void setTouch(boolean touch) {
        this.touch = touch;
    }
}
